﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <script src="../0_System_file/js/jquery.min.js"></script>
    <script src="../0_System_file/js/jquery.easyui.min.js"></script>
    <script src="../0_System_file/js/validatebox.js"></script>
    <link href="../0_System_file/themes/default/easyui.css" rel="stylesheet" />
    <link href="../0_System_file/themes/icon.css" rel="stylesheet" />
    <link href="../0_System_file/themes/Site (1).css" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
        //使用Javascript去创建DataGrid控件
        $('#dg').datagrid({
            fitColumns: true,//真正的自动展开/收缩的大小，以适应网格宽度，防止水平滚动
            toolbar: "#tb",//通过选择器指定的工具栏
            pagination: true,//如果为true，则在datagrid空间底部显示分页工具栏
            //fit: true,//如果为true时面板大小将自适应父容器
            singleSelect: true,//如果为true，则只允许选择一行
            rownumbers:true,//如果为true，则显示一个行号列
            url: "/10_Json/datagrid_data1.json",
            columns: [[
                { field: "productid", title: "商铺ID", width: 100 },
                { field: "productname", title: "商铺名称", width: 100 },
                { field: "unitcost", title: "价格", width: 100 }
            ]]
        });
        //添加
        $("#btnAdd").click(function () {
            $("#dlg").dialog({ width: 800, height: 450 })
                    .dialog("setTitle", "添加用户")
                   .dialog("open");
            $("#frml").attr("src", "/02_addmember.html");

        });
        //修改
        $("#btnUpdate").click(function () {
            var row = $("#dg").datagrid("getSelected");
            if (row != null) {
                $("#dlg").dialog({ width: 800, height: 450 }).dialog("setTitle", "修改店铺").dialog("open");
                $("#frml").attr("src", "/06_UpdateMember.html");
                //$.messager.alert("提示", "修改成功 " + row.productid, "warning");
            } else {
                $.messager.alert("提示", "请选择需要编辑的行", "warning");
            }
        });
            //删除
        $("#btnDelete").click(function () {
            var row = $("#dg").datagrid("getSelected");
            if (row != null) {
                $.messager.alert("提示", "删除成功 " + row.productid, "warning");
            } else {
                $.messager.alert("提示", "请选择需要删除的行", "warning");
            }
        });
            //挂失/锁定
        $("#btnLock").click(function () {
            var row = $("#dg").datagrid("getSelected");
            if (row != null) {
            $("#dlg").dialog({ width: 400, height: 400 })
                    .dialog("setTitle", "挂失/锁定")
                   .dialog("open");
            $("#frml").attr("src", "/04_LockMember.html");
            } else {
                $.messager.alert("提示", "请选择需要挂失的会员", "warning");
            }
        });
            //会员换卡
        $("#btnReLoad").click(function () {
            var row = $("#dg").datagrid("getSelected");
            if (row != null) {
                $("#dlg").dialog({ width: 400, height: 400 })
                        .dialog("setTitle", "会员换卡")
                       .dialog("open");
                $("#frml").attr("src", "/03_ChangeCard.html");
            } else {
                $.messager.alert("提示", "请选择需要换卡的会员", "warning");
            }
        });

            //会员转账
        $("#btnLockIn").click(function () {
            var row = $("#dg").datagrid("getSelected");
            if (row != null) {
                $("#dlg").dialog({ width: 400, height: 400 })
                        .dialog("setTitle", "会员转账")
                       .dialog("open");
                $("#frml").attr("src", "/05_Thansfer.html");
            } else {
                $.messager.alert("提示", "请选择转账的会员", "warning");
            }
        });
        $.extend($.messager.defaults, {
            ok: "确定",
            cancel: "取消"
        });
        });

        //导出
        var idTmr;
        function getExplorer() {
            var explorer = window.navigator.userAgent;
            //ie  
            if (explorer.indexOf("MSIE") >= 0) {
                return 'ie';
            }
                //firefox  
            else if (explorer.indexOf("Firefox") >= 0) {
                return 'Firefox';
            }
                //Chrome  
            else if (explorer.indexOf("Chrome") >= 0) {
                return 'Chrome';
            }
                //Opera  
            else if (explorer.indexOf("Opera") >= 0) {
                return 'Opera';
            }
                //Safari  
            else if (explorer.indexOf("Safari") >= 0) {
                return 'Safari';
            }
        }
        function method5(tableid) {
            if (getExplorer() == 'ie') {
                var curTbl = document.getElementById(tableid);
                var oXL = new ActiveXObject("Excel.Application");
                var oWB = oXL.Workbooks.Add();
                var xlsheet = oWB.Worksheets(1);
                var sel = document.body.createTextRange();
                sel.moveToElementText(curTbl);
                sel.select();
                sel.execCommand("Copy");
                xlsheet.Paste();
                oXL.Visible = true;

                try {
                    var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
                } catch (e) {
                    print("Nested catch caught " + e);
                } finally {
                    oWB.SaveAs(fname);
                    oWB.Close(savechanges = false);
                    oXL.Quit();
                    oXL = null;
                    idTmr = window.setInterval("Cleanup();", 1);
                }

            }
            else {
                tableToExcel(tableid)
            }
        }
        function Cleanup() {
            window.clearInterval(idTmr);
            CollectGarbage();
        }
        var tableToExcel = (function () {
            var uri = 'data:application/vnd.ms-excel;base64,',
                    template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>',
                    base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) },
                    format = function (s, c) {
                        return s.replace(/{(\w+)}/g,
                                function (m, p) { return c[p]; })
                    }
            return function (table, name) {
                if (!table.nodeType) table = document.getElementById(table)
                var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
                window.location.href = uri + base64(format(template, ctx))
            }
        })()
</script>
</head>
<body>
    <div>
        <a id="btnAdd" class="easyui-linkbutton" data-options="iconCls:'icon-add'">增加</a>
        <a id="btnUpdate" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
        <a id="btnDelete" class="easyui-linkbutton" data-options="iconCls:'icon-remove'">删除</a>
        <a id="btnLock" class="easyui-linkbutton" data-options="iconCls:'icon-lock'">挂失/锁定</a>
        <a id="btnLockIn" class="easyui-linkbutton" data-options="iconCls:'icon-icon1'">会员转账</a>
        <a id="btnReLoad" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">会员换卡</a>
        <button type="button" onclick="method5('dg')">导出Excel方法五</button>  
        <a id="btnExcelIn" class="easyui-linkbutton" data-options="iconCls:'icon-icon2'">导入Excel</a>

    </div>
    <div>
        会员卡号：<input id="Text1" type="text" style="width:80px;" />
        会员姓名：<input id="Text1" type="text" style="width:80px;" />
        电话：<input id="Text1" type="text" style="width:80px;" />
        会员等级：<select id="Select1" style="width:80px;">
            <option></option>

        </select>
        状态：<select id="Select1" style="width:80px;">
            <option></option>

        </select>
        <a href="otherpage.php" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
    </div>
    <div id="dlg" class="easyui-dialog" data-options="iconCls:'icon-save',resizable:true,model:true,closed:true">
        <iframe id="frml" width="99%" height="99%" frameborder="0"></iframe>
    </div>
    <div>
        <table id="dg"></table>
    </div>

</body>
</html>
